Skip to content

Conversation

@jdonszelmann
Copy link
Contributor

@jdonszelmann jdonszelmann commented Sep 8, 2025

Supersedes #140010
Tracking issue: #125418

Getting started:

#![feature(eii)]

#[eii(eii1)]
pub fn decl1(x: u64) 
// body optional (it's the default)
{
    println!("default {x}");
}

// in another crate, maybe
#[eii1]
pub fn decl2(x: u64) {
    println!("explicit {x}");
}

fn main() {
    decl1(4);
}

@rustbot rustbot added A-attributes Area: Attributes (`#[…]`, `#![…]`) A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-clippy Relevant to the Clippy team. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Sep 8, 2025
@rust-log-analyzer

This comment has been minimized.

// `SymbolExportLevel::Rust` export level but may end up being exported in dylibs.
|| codegen_attrs.flags.contains(CodegenFnAttrFlags::USED_COMPILER)
|| codegen_attrs.flags.contains(CodegenFnAttrFlags::USED_LINKER)
// Right now, the only way to get "foreign item symbol aliases" is by being an EII-implementation.
Copy link
Contributor Author

@jdonszelmann jdonszelmann Sep 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: do we need this:

  • option 1: we do and implement our own reachability analysis based on it separate from RUSTC_STD_INTERNAL_SYMBOL.
  • option 2: we don't cause we also use RUSTC_STD_INTERNAL_SYMBOL on all EIIs. In that case we should rename STD_INTERNAL_SYMBOL
  • option 3: same as option 2 but maybe we shouldn't use RUSTC_STD_INTERNAL_SYMBOL in the first place; we leave it as-is and create a new flag thta's like it but specifically for EIIs and named something else like RUSTC_USED_BY_NONDIRECT_DEP_CRATE or whatever nicer name we can think of that (as long as it doesn't use STD since it's not really specific to that anymore)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

despite STD_INTERNAL_SYMBOL working, and we can test with it for a bit, this is not the way we should do it. i.e. not option 2.


#[eii(eii1)]
pub fn decl1(x: u64) {
//~^ WARN function `decl1` is never used
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It took me a little bit to decide what is the expected behavior here. We might want to remove this warning. Defaults are in some way expected to be unused. However, here we can prove it because the explicit impl is in the same crate hence the warning.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removing the warning actually makes the code a tiny bit trickier

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@jdonszelmann
Copy link
Contributor Author

@bors2 try @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors

This comment has been minimized.

rust-bors bot added a commit that referenced this pull request Sep 9, 2025
[DONT MERGE] externally implementable items
@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Sep 9, 2025
@rust-bors
Copy link

rust-bors bot commented Sep 9, 2025

☀️ Try build successful (CI)
Build commit: d5a6633 (d5a66337e06d3b77a1ab8f6793055535195c3ae9, parent: 364da5d88d772fa40fb20353443595385443ac25)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (d5a6633): comparison URL.

Overall result: ❌ regressions - please read the text below

Benchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf.

Next Steps: If you can justify the regressions found in this try perf run, please do so in sufficient writing along with @rustbot label: +perf-regression-triaged. If not, please fix the regressions and do another perf run. If its results are neutral or positive, the label will be automatically removed.

@bors rollup=never
@rustbot label: -S-waiting-on-perf +perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
0.3% [0.1%, 1.5%] 19
Regressions ❌
(secondary)
0.4% [0.1%, 1.0%] 44
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.0% [-0.1%, -0.0%] 4
All ❌✅ (primary) 0.3% [0.1%, 1.5%] 19

Max RSS (memory usage)

Results (primary 1.7%, secondary 3.9%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
1.7% [0.6%, 2.3%] 6
Regressions ❌
(secondary)
4.7% [1.1%, 11.2%] 16
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.1% [-2.9%, -1.2%] 2
All ❌✅ (primary) 1.7% [0.6%, 2.3%] 6

Cycles

Results (primary 3.1%, secondary -1.3%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
3.1% [3.1%, 3.1%] 1
Regressions ❌
(secondary)
3.2% [2.5%, 3.6%] 3
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.8% [-4.1%, -2.0%] 9
All ❌✅ (primary) 3.1% [3.1%, 3.1%] 1

Binary size

Results (primary 0.0%, secondary 0.1%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
0.0% [0.0%, 0.1%] 93
Regressions ❌
(secondary)
0.1% [0.0%, 0.3%] 61
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.0% [0.0%, 0.1%] 93

Bootstrap: 468.052s -> 471.14s (0.66%)
Artifact size: 387.52 MiB -> 390.25 MiB (0.71%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Sep 9, 2025
@jdonszelmann
Copy link
Contributor Author

Well, shit. I think I know some fixes but I hoped this wouldn't happen

@bors
Copy link
Collaborator

bors commented Sep 17, 2025

☔ The latest upstream changes (presumably #146666) made this pull request unmergeable. Please resolve the merge conflicts.

@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Collaborator

bors commented Oct 16, 2025

☔ The latest upstream changes (presumably #146221) made this pull request unmergeable. Please resolve the merge conflicts.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer
Copy link
Collaborator

The job x86_64-gnu-gcc failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
test [ui] tests/ui/editions/never-type-fallback.rs#e2021 ... ok
test [ui] tests/ui/editions/unsafe-attr-edition-span.rs#e2021 ... ok
test [ui] tests/ui/editions/unsafe-attr-edition-span.rs#e2024 ... ok
test [ui] tests/ui/editions/never-type-fallback.rs#e2024 ... ok
test [ui] tests/ui/eii/cross_crate_wrong_ty.rs ... ok
test [ui] tests/ui/eii/cross_crate.rs ... ok
test [ui] tests/ui/eii/codegen_single_crate.rs ... FAILED
test [ui] tests/ui/eii/codegen_cross_crate.rs ... FAILED
test [ui] tests/ui/eii/default/local_crate.rs ... FAILED
test [ui] tests/ui/eii/default/local_crate_explicit.rs ... FAILED
test [ui] tests/ui/eii/default/call_default.rs ... FAILED
test [ui] tests/ui/eii/default/call_impl.rs ... FAILED
test [ui] tests/ui/eii/errors.rs ... ok
test [ui] tests/ui/eii/duplicate/duplicate1.rs ... ok
test [ui] tests/ui/eii/privacy2.rs ... ok
test [ui] tests/ui/eii/duplicate/duplicate2.rs ... ok
test [ui] tests/ui/eii/privacy1.rs ... FAILED
test [ui] tests/ui/eii/subtype_1.rs ... ok
test [ui] tests/ui/eii/subtype_3.rs ... ok
test [ui] tests/ui/eii/subtype_2.rs ... ok
test [ui] tests/ui/eii/subtype_4.rs ... ok
test [ui] tests/ui/eii/unsafe_impl_ok.rs ... ok
test [ui] tests/ui/eii/unsafe_impl_err.rs ... ok
test [ui] tests/ui/eii/wrong_ret_ty.rs ... ok
test [ui] tests/ui/eii/wrong_ty.rs ... ok
test [ui] tests/ui/eii/wrong_target.rs ... ok
test [ui] tests/ui/eii/wrong_ty_2.rs ... ok
test [ui] tests/ui/empty/empty-comment.rs ... ok
test [ui] tests/ui/empty/empty-attributes.rs ... ok
test [ui] tests/ui/empty/empty-linkname.rs ... ok
test [ui] tests/ui/eii/duplicate/duplicate3.rs ... ok
test [ui] tests/ui/empty/empty-never-array.rs ... ok
test [ui] tests/ui/empty/empty-macro-use.rs ... ok
test [ui] tests/ui/empty/empty-struct-braces-expr.rs ... ok
test [ui] tests/ui/empty/empty-struct-braces-pat-1.rs ... ok
test [ui] tests/ui/empty/empty-struct-braces-pat-2.rs ... ok
---
test [ui] tests/ui/feature-gates/feature-gate-doc_masked.rs ... ok
test [ui] tests/ui/feature-gates/feature-gate-doc_notable_trait.rs ... ok
test [ui] tests/ui/feature-gates/feature-gate-effective-target-features.rs#default ... ok
test [ui] tests/ui/feature-gates/feature-gate-effective-target-features.rs#feature ... ok
test [ui] tests/ui/feature-gates/feature-gate-eii-internals.rs ... ok
test [ui] tests/ui/feature-gates/feature-gate-eii.rs ... ok
test [ui] tests/ui/feature-gates/feature-gate-exhaustive-patterns.rs ... ok
test [ui] tests/ui/feature-gates/feature-gate-ergonomic-clones.rs ... ok
test [ui] tests/ui/feature-gates/feature-gate-explicit-extern-abis.rs#current ... ok
test [ui] tests/ui/feature-gates/feature-gate-explicit-extern-abis.rs#future_feature ... ok
test [ui] tests/ui/feature-gates/feature-gate-explicit-extern-abis.rs#current_feature ... ok
---
---- [ui] tests/ui/eii/codegen_single_crate.rs stdout ----

error: test compilation failed although it shouldn't!
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/eii/codegen_single_crate.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2" "-Zcodegen-backend=gcc" "--target=x86_64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "-O" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/eii/codegen_single_crate/a" "-A" "internal_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers"
stdout: none
--- stderr -------------------------------
error: linking with `cc` failed: exit status: 1
   |
   = note:  "cc" "-m64" "/tmp/rustcoGFOuv/symbols.o" "<1 object files omitted>" "-Wl,--as-needed" "-Wl,-Bdynamic" "<sysroot>/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-263465a51fef9918.so" "-Wl,-Bstatic" "<sysroot>/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-*.rlib" "-Wl,-Bdynamic" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-L" "/tmp/rustcoGFOuv/raw-dylibs" "-B<sysroot>/lib/rustlib/x86_64-unknown-linux-gnu/bin/gcc-ld" "-B<sysroot>/lib/rustlib/x86_64-unknown-linux-gnu/bin/gcc-ld" "-fuse-ld=lld" "-Wl,--eh-frame-hdr" "-Wl,-z,noexecstack" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "<sysroot>/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/eii/codegen_single_crate/a" "-Wl,--gc-sections" "-pie" "-Wl,-z,relro,-z,now" "-Wl,-O1" "-Wl,--strip-debug" "-nodefaultlibs" "-Wl,-rpath,$ORIGIN/../../../../stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib,--enable-new-dtags,-z,origin"
   = note: some arguments are omitted. use `--verbose` to show all linker arguments
   = note: rust-lld: error: undefined symbol: hello
           >>> referenced by fake.c
           >>>               /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/eii/codegen_single_crate/a.codegen_single_crate.d714f39b1622a531-cgu.0.rcgu.o:(codegen_single_crate::main::h3a59f14c0c7de01b)
           collect2: error: ld returned 1 exit status
           

error: aborting due to 1 previous error
------------------------------------------

---- [ui] tests/ui/eii/codegen_single_crate.rs stdout end ----
---- [ui] tests/ui/eii/codegen_cross_crate.rs stdout ----

error: test compilation failed although it shouldn't!
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/eii/codegen_cross_crate.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2" "-Zcodegen-backend=gcc" "--target=x86_64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/eii/codegen_cross_crate/a" "-A" "internal_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/eii/codegen_cross_crate/auxiliary" "-O"
stdout: none
--- stderr -------------------------------
error: linking with `cc` failed: exit status: 1
   |
   = note:  "cc" "-m64" "/tmp/rustcfBG2ie/symbols.o" "<1 object files omitted>" "-Wl,--as-needed" "-Wl,-Bstatic" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/eii/codegen_cross_crate/auxiliary/libcodegen2.rlib" "-Wl,-Bdynamic" "<sysroot>/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-263465a51fef9918.so" "-Wl,-Bstatic" "<sysroot>/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-*.rlib" "-Wl,-Bdynamic" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-L" "/tmp/rustcfBG2ie/raw-dylibs" "-B<sysroot>/lib/rustlib/x86_64-unknown-linux-gnu/bin/gcc-ld" "-B<sysroot>/lib/rustlib/x86_64-unknown-linux-gnu/bin/gcc-ld" "-fuse-ld=lld" "-Wl,--eh-frame-hdr" "-Wl,-z,noexecstack" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/eii/codegen_cross_crate/auxiliary" "-L" "<sysroot>/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/eii/codegen_cross_crate/a" "-Wl,--gc-sections" "-pie" "-Wl,-z,relro,-z,now" "-Wl,-O1" "-Wl,--strip-debug" "-nodefaultlibs" "-Wl,-rpath,$ORIGIN/../../../../stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib,--enable-new-dtags,-z,origin"
   = note: some arguments are omitted. use `--verbose` to show all linker arguments
   = note: rust-lld: error: undefined symbol: decl1
           >>> referenced by fake.c
           >>>               /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/eii/codegen_cross_crate/a.codegen_cross_crate.af5b9a5664e07c02-cgu.0.rcgu.o:(codegen_cross_crate::main::hc496279e8d4df038)
           collect2: error: ld returned 1 exit status
           

error: aborting due to 1 previous error
------------------------------------------

---- [ui] tests/ui/eii/codegen_cross_crate.rs stdout end ----
---- [ui] tests/ui/eii/default/local_crate.rs stdout ----

error: test compilation failed although it shouldn't!
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/eii/default/local_crate.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2" "-Zcodegen-backend=gcc" "--target=x86_64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "-O" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/eii/default/local_crate/a" "-A" "internal_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers"
stdout: none
--- stderr -------------------------------
error: linking with `cc` failed: exit status: 1
   |
   = note:  "cc" "-m64" "/tmp/rustcnaQ5LY/symbols.o" "<1 object files omitted>" "-Wl,--as-needed" "-Wl,-Bdynamic" "<sysroot>/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-263465a51fef9918.so" "-Wl,-Bstatic" "<sysroot>/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-*.rlib" "-Wl,-Bdynamic" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-L" "/tmp/rustcnaQ5LY/raw-dylibs" "-B<sysroot>/lib/rustlib/x86_64-unknown-linux-gnu/bin/gcc-ld" "-B<sysroot>/lib/rustlib/x86_64-unknown-linux-gnu/bin/gcc-ld" "-fuse-ld=lld" "-Wl,--eh-frame-hdr" "-Wl,-z,noexecstack" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "<sysroot>/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/eii/default/local_crate/a" "-Wl,--gc-sections" "-pie" "-Wl,-z,relro,-z,now" "-Wl,-O1" "-Wl,--strip-debug" "-nodefaultlibs" "-Wl,-rpath,$ORIGIN/../../../../../stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib,--enable-new-dtags,-z,origin"
   = note: some arguments are omitted. use `--verbose` to show all linker arguments
   = note: rust-lld: error: undefined symbol: decl1
           >>> referenced by fake.c
           >>>               /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/eii/default/local_crate/a.local_crate.465a9d8cb614c192-cgu.0.rcgu.o:(local_crate::main::h82d0e1b84ed3244a)
           collect2: error: ld returned 1 exit status
           

error: aborting due to 1 previous error
------------------------------------------

---- [ui] tests/ui/eii/default/local_crate.rs stdout end ----
---- [ui] tests/ui/eii/default/local_crate_explicit.rs stdout ----

error: test compilation failed although it shouldn't!
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/eii/default/local_crate_explicit.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2" "-Zcodegen-backend=gcc" "--target=x86_64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "-O" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/eii/default/local_crate_explicit/a" "-A" "internal_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers"
stdout: none
--- stderr -------------------------------
warning: function `decl1` is never used
##[warning]  --> /checkout/tests/ui/eii/default/local_crate_explicit.rs:6:8
   |
LL | pub fn decl1(x: u64) {
   |        ^^^^^
   |
   = note: `#[warn(dead_code)]` (part of `#[warn(unused)]`) on by default

error: linking with `cc` failed: exit status: 1
   |
   = note:  "cc" "-m64" "/tmp/rustcqJTXpd/symbols.o" "<1 object files omitted>" "-Wl,--as-needed" "-Wl,-Bdynamic" "<sysroot>/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-263465a51fef9918.so" "-Wl,-Bstatic" "<sysroot>/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-*.rlib" "-Wl,-Bdynamic" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-L" "/tmp/rustcqJTXpd/raw-dylibs" "-B<sysroot>/lib/rustlib/x86_64-unknown-linux-gnu/bin/gcc-ld" "-B<sysroot>/lib/rustlib/x86_64-unknown-linux-gnu/bin/gcc-ld" "-fuse-ld=lld" "-Wl,--eh-frame-hdr" "-Wl,-z,noexecstack" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "<sysroot>/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/eii/default/local_crate_explicit/a" "-Wl,--gc-sections" "-pie" "-Wl,-z,relro,-z,now" "-Wl,-O1" "-Wl,--strip-debug" "-nodefaultlibs" "-Wl,-rpath,$ORIGIN/../../../../../stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib,--enable-new-dtags,-z,origin"
   = note: some arguments are omitted. use `--verbose` to show all linker arguments
   = note: rust-lld: error: undefined symbol: decl1
           >>> referenced by fake.c
           >>>               /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/eii/default/local_crate_explicit/a.local_crate_explicit.e4b4dfe0eed95e5b-cgu.0.rcgu.o:(local_crate_explicit::main::h0f67957eedeef90b)
           collect2: error: ld returned 1 exit status
           

error: aborting due to 1 previous error; 1 warning emitted
------------------------------------------

---- [ui] tests/ui/eii/default/local_crate_explicit.rs stdout end ----
---- [ui] tests/ui/eii/default/call_default.rs stdout ----

error: test compilation failed although it shouldn't!
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/eii/default/call_default.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2" "-Zcodegen-backend=gcc" "--target=x86_64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "-O" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/eii/default/call_default/a" "-A" "internal_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/eii/default/call_default/auxiliary"
stdout: none
--- stderr -------------------------------
error: linking with `cc` failed: exit status: 1
   |
   = note:  "cc" "-m64" "/tmp/rustcjnpExT/symbols.o" "<2 object files omitted>" "-Wl,--as-needed" "-Wl,-Bstatic" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/eii/default/call_default/auxiliary/libdecl_with_default.rlib" "<sysroot>/lib/rustlib/x86_64-unknown-linux-gnu/lib/{libstd-*,libpanic_unwind-*,libobject-*,libmemchr-*,libaddr2line-*,libgimli-*,libcfg_if-*,librustc_demangle-*,libstd_detect-*,libhashbrown-*,librustc_std_workspace_alloc-*,libminiz_oxide-*,libadler2-*,libunwind-*,liblibc-*,librustc_std_workspace_core-*,liballoc-*,libcore-*,libcompiler_builtins-*}.rlib" "-Wl,-Bdynamic" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-L" "/tmp/rustcjnpExT/raw-dylibs" "-B<sysroot>/lib/rustlib/x86_64-unknown-linux-gnu/bin/gcc-ld" "-B<sysroot>/lib/rustlib/x86_64-unknown-linux-gnu/bin/gcc-ld" "-fuse-ld=lld" "-Wl,--eh-frame-hdr" "-Wl,-z,noexecstack" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/eii/default/call_default/auxiliary" "-L" "<sysroot>/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/eii/default/call_default/a" "-Wl,--gc-sections" "-pie" "-Wl,-z,relro,-z,now" "-Wl,-O1" "-Wl,--strip-debug" "-nodefaultlibs" "-Wl,-rpath,$ORIGIN/../../../../../stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib,--enable-new-dtags,-z,origin"
   = note: some arguments are omitted. use `--verbose` to show all linker arguments
   = note: rust-lld: error: undefined symbol: decl1
           >>> referenced by fake.c
           >>>               /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/eii/default/call_default/a.call_default.e65edcad8a79f346-cgu.0.rcgu.o:(call_default::main::h2374fdba4a031467)
           collect2: error: ld returned 1 exit status
           

error: aborting due to 1 previous error
------------------------------------------

---- [ui] tests/ui/eii/default/call_default.rs stdout end ----
---- [ui] tests/ui/eii/default/call_impl.rs stdout ----

error: test compilation failed although it shouldn't!
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/eii/default/call_impl.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2" "-Zcodegen-backend=gcc" "--target=x86_64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "-O" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/eii/default/call_impl/a" "-A" "internal_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/eii/default/call_impl/auxiliary"
stdout: none
--- stderr -------------------------------
error: linking with `cc` failed: exit status: 1
   |
   = note:  "cc" "-m64" "/tmp/rustc9KLo4v/symbols.o" "<2 object files omitted>" "-Wl,--as-needed" "-Wl,-Bstatic" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/eii/default/call_impl/auxiliary/{libimpl1,libdecl_with_default}.rlib" "<sysroot>/lib/rustlib/x86_64-unknown-linux-gnu/lib/{libstd-*,libpanic_unwind-*,libobject-*,libmemchr-*,libaddr2line-*,libgimli-*,libcfg_if-*,librustc_demangle-*,libstd_detect-*,libhashbrown-*,librustc_std_workspace_alloc-*,libminiz_oxide-*,libadler2-*,libunwind-*,liblibc-*,librustc_std_workspace_core-*,liballoc-*,libcore-*,libcompiler_builtins-*}.rlib" "-Wl,-Bdynamic" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-L" "/tmp/rustc9KLo4v/raw-dylibs" "-B<sysroot>/lib/rustlib/x86_64-unknown-linux-gnu/bin/gcc-ld" "-B<sysroot>/lib/rustlib/x86_64-unknown-linux-gnu/bin/gcc-ld" "-fuse-ld=lld" "-Wl,--eh-frame-hdr" "-Wl,-z,noexecstack" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/eii/default/call_impl/auxiliary" "-L" "<sysroot>/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/eii/default/call_impl/a" "-Wl,--gc-sections" "-pie" "-Wl,-z,relro,-z,now" "-Wl,-O1" "-Wl,--strip-debug" "-nodefaultlibs" "-Wl,-rpath,$ORIGIN/../../../../../stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib,--enable-new-dtags,-z,origin"
   = note: some arguments are omitted. use `--verbose` to show all linker arguments
   = note: rust-lld: error: undefined symbol: decl1
           >>> referenced by fake.c
           >>>               /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/eii/default/call_impl/a.call_impl.84c521ed2ec1c8e6-cgu.0.rcgu.o:(call_impl::main::hb5179d65ef7249e4)
           collect2: error: ld returned 1 exit status
           

error: aborting due to 1 previous error
------------------------------------------

---- [ui] tests/ui/eii/default/call_impl.rs stdout end ----
---- [ui] tests/ui/eii/privacy1.rs stdout ----

error: test compilation failed although it shouldn't!
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/eii/privacy1.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2" "-Zcodegen-backend=gcc" "--target=x86_64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "-O" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/eii/privacy1/a" "-A" "internal_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/eii/privacy1/auxiliary"
stdout: none
--- stderr -------------------------------
error: linking with `cc` failed: exit status: 1
   |
   = note:  "cc" "-m64" "/tmp/rustca3LSPj/symbols.o" "<1 object files omitted>" "-Wl,--as-needed" "-Wl,-Bstatic" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/eii/privacy1/auxiliary/libcodegen1.rlib" "-Wl,-Bdynamic" "<sysroot>/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-263465a51fef9918.so" "-Wl,-Bstatic" "<sysroot>/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-*.rlib" "-Wl,-Bdynamic" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-L" "/tmp/rustca3LSPj/raw-dylibs" "-B<sysroot>/lib/rustlib/x86_64-unknown-linux-gnu/bin/gcc-ld" "-B<sysroot>/lib/rustlib/x86_64-unknown-linux-gnu/bin/gcc-ld" "-fuse-ld=lld" "-Wl,--eh-frame-hdr" "-Wl,-z,noexecstack" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/eii/privacy1/auxiliary" "-L" "<sysroot>/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/eii/privacy1/a" "-Wl,--gc-sections" "-pie" "-Wl,-z,relro,-z,now" "-Wl,-O1" "-Wl,--strip-debug" "-nodefaultlibs" "-Wl,-rpath,$ORIGIN/../../../../stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib,--enable-new-dtags,-z,origin"
   = note: some arguments are omitted. use `--verbose` to show all linker arguments
   = note: rust-lld: error: undefined symbol: decl1
           >>> referenced by fake.c
           >>>               codegen1.codegen1.79c2ab5f9ddba2c9-cgu.0.rcgu.o:(codegen1::local_call_decl1::hef22ca0cc9acedd0) in archive /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/eii/privacy1/auxiliary/libcodegen1.rlib
           
           rust-lld: error: undefined symbol: decl2
           >>> referenced by fake.c
           >>>               /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/eii/privacy1/a.privacy1.c762a65e2a5a438e-cgu.0.rcgu.o:(privacy1::main::hf427a2a60776b8db)
           collect2: error: ld returned 1 exit status
           

error: aborting due to 1 previous error
------------------------------------------

---- [ui] tests/ui/eii/privacy1.rs stdout end ----

failures:
    [ui] tests/ui/eii/codegen_single_crate.rs
    [ui] tests/ui/eii/codegen_cross_crate.rs
    [ui] tests/ui/eii/default/local_crate.rs
    [ui] tests/ui/eii/default/local_crate_explicit.rs
    [ui] tests/ui/eii/default/call_default.rs
    [ui] tests/ui/eii/default/call_impl.rs
    [ui] tests/ui/eii/privacy1.rs

test result: FAILED. 19248 passed; 7 failed; 734 ignored; 0 measured; 0 filtered out; finished in 758.39s

Some tests failed in compiletest suite=ui mode=ui host=x86_64-unknown-linux-gnu target=x86_64-unknown-linux-gnu
Bootstrap failed while executing `--stage 2 test tests --test-codegen-backend gcc --skip tests/coverage --skip tests/coverage-run-rustdoc --skip tests/rustdoc --skip tests/rustdoc-gui --skip tests/rustdoc-js --skip tests/rustdoc-js-std --skip tests/rustdoc-json --skip tests/rustdoc-ui --set rust.codegen-backends=["llvm","gcc"]`

For more information how to resolve CI failures of this job, visit this link.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please leave some comments on the tests stating what they are testing. I can usually deduce it from the source, but then I'm left scratching my head when I see two very similar ones.

I'm just as much at fault of writing tests like this, but I also know I have ended up scratching my head while looking at them half a year later

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fair

@@ -0,0 +1,16 @@
error[E0050]: `other` has 0 parameters but #[foo] requires it to have 1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already have signature comparison logic for trait vs impl mismatches. Can we reuse that as it's already been quite tuned to show lots of details and make suggestions

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so the logic I used is for a large part the same, you'll see many signatures match and I call into it a few times. The reason it's different, is that we have to check there are no generics, we don't deal with a self type, and diagnostics can't refer to a trait obviously. I tried reusing parts, but I'm not sure we can much more than I do right now.

/// This function is an implementation of an externally implementable item (EII).
/// This means, there was an EII declared somewhere and this function is the
/// implementation that should be run when the declaration is called.
pub eii_impls: ThinVec<EiiImpl>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is it a vec and not an option?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one function could be the implementation of multiple EIIs. A panic handler could also be the integer overflow handler simultaneously

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm... Doesn't sound too compelling to support, but if the complexity is basically just in the collector/checker (where it's just a loop, so not a problem) and not in the macros or such, then it's ok.

Def needs tests tho. Also a test using the same eii attribute twice. Or one function defining two different eiis at the same time

span,
vis: ast::Visibility { span, kind: ast::VisibilityKind::Inherited, tokens: None },
kind: ast::ItemKind::ForeignMod(ast::ForeignMod {
extern_span: span,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be computed from the fn's extern span, everything but the generated Rust has one.

Various other uses of the fallback span may also have better spans to be used

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not too excited about some of the parser stuff, but I think that's just the status of most builtin macros rn

ribs: &[Rib<'ra>],
ignore_binding: Option<NameBinding<'ra>>,
) -> Option<LexicalScopeBinding<'ra>> {
assert!(ns == TypeNS || ns == ValueNS);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there tests for various situations with naming conflicts?

Copy link
Contributor Author

@jdonszelmann jdonszelmann Oct 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm, unsure, In theory there shouldn't be any issue, EII attributes are simply part of the macro namespace and act exactly as other macros. The reason this assertion had to be removed is that we use the defid of that macro as an identifier for the EII itself - with is we look up its signature when type checking for example. And we used to effectively assert that all defids of macros were filtered out at this point.


// iterate over all items in the current crate
// FIXME(speed up)
for id in tcx.hir_crate_items(()).definitions() {

This comment was marked as resolved.


// iterate over all items in the current crate
// FIXME(speed up)
for id in tcx.hir_crate_items(()).definitions() {

This comment was marked as resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-attributes Area: Attributes (`#[…]`, `#![…]`) A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. perf-regression Performance regression. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-clippy Relevant to the Clippy team. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants